/* tslint:disable:max-line-length */
import {User} from '../user/user.model';

import {Message} from '../message/message.model';
import {MessagesService} from '../message/messages.service';
import {ThreadsService} from '../thread/threads.service';
import {UsersService} from '../user/users.service';
import {ChatHttpComponent} from '../chat-http/chat-http.component';
import {HttpClient} from 'selenium-webdriver/http';
import {OnInit} from '@angular/core';
import {Http} from '@angular/http';
import {Observable} from 'rxjs/Observable';

// the person using the app us Juliet

const me: User = new User('Juliet', 'assets/images/avatars/female-avatar-1.png');


export class ChatProductData {

  static initialMessages: Array<Message> = [];

  static init(dataSource: Observable<any>,
              messagesService: MessagesService,
              threadsService: ThreadsService,
              UsersService: UsersService): void {

    // TODO make `messages` hot
    messagesService.messages.subscribe(() => ({}));

    // set "Juliet" as the current user
    UsersService.setCurrentUser(me);
    // chathttp.messages.subscribe((data) => this.initialMessages = data);
    // create the initial messages
    dataSource.subscribe((data) => this.initialMessages = data)
    this.initialMessages.map((message: Message) =>
      messagesService.addMessage(message)
    )
    ;
  }

}
